home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / gpib.h.z / gpib.h
C/C++ Source or Header  |  1992-04-03  |  9KB  |  219 lines

  1. /*
  2.  * GPIB software definitions
  3.  */
  4.  
  5. /* rev-c emulation stuff */
  6.  
  7. /* board status mask */
  8. #define S_ERR    ERR    /* error */
  9. #define S_TIMO    TIMO    /* timeout */
  10. #define S_END    END    /* EOI or eos  */
  11. #define S_SRQI    SRQI    /* srq asserted */
  12. #define S_RQS    RQS    /* request service */
  13. #define S_CMPL    CMPL    /* I/O complete */
  14. #define S_LOK    LOK    /* local lockout */
  15. #define S_REM    REM    /* remote */
  16. #define S_CIC    CIC    /* controller in charge  */
  17. #define S_ATN    ATN    /* attention asserted  */
  18. #define S_TACS    TACS    /* talker active  */
  19. #define S_LACS    LACS    /* listener active  */
  20. #define S_DTAS    DTAS    /* device trigger  */
  21. #define S_DCAS    DCAS    /* device clear  */
  22.  
  23. #define MBITS (S_TIMO|S_END|S_SRQI|S_LOK|S_REM|S_CIC|S_TACS|S_LACS|S_DTAS|S_DCAS)
  24.  
  25.  
  26. /* gpib signals */
  27. #define SG_SRQI 8
  28. #define SG_LOK  6
  29. #define SG_REM  5
  30. #define SG_CIC  4
  31. #define SG_TACS 3
  32. #define SG_LACS 2
  33. #define SG_DTAS 1
  34. #define SG_DCAS 0
  35. #define N_SG      9  /* number of signals */
  36.  
  37. #define NO_SG   (int (*)())0    /* no signal */
  38. #define DFLT_SG (int (*)())1    /* default */
  39.  
  40. struct achain {
  41.     long    a_buf;
  42.     short    a_cnt;
  43. };
  44. #define MAXDMA    0x10000            /* most byte we'll transfer */
  45. #define NCHAIN    (MAXDMA/NBPP + 2)    /* number of achain entries needed */
  46.  
  47. /* structure exits one per gpib board in system */
  48.     struct kboard {    /* through b_sig must match struct board in ugpib.h */
  49.         word_t  b_uflags;          /* user flags (see below) */
  50.     struct ibregs * b_addr;    /* I/O port address */
  51.     char    b_pad,b_sad;       /* primary and secondary gpib address */
  52.     char    b_eos;             /* end-of-string character */
  53.     word_t  b_tmo;             /* timeout value (see below) */
  54.     char    b_ppe;             /* parallel poll enable byte */
  55.     char    b_irq;             /* Interrupt level */
  56.     char    b_ivec;            /* interrupt vector number */
  57.     char    b_sig;             /* UNIX signal to send */
  58.     /* remainder is internal structure not accessable by ioctl */
  59.     unsigned b_count;           /* bytes transfered */
  60.     word_t  b_error;           /* error code */
  61.     word_t  b_flags;           /* internal board flags (see below) */
  62.     word_t  b_statmem;         /* status bits retained between calls */
  63.     word_t  b_endmem;          /* END status bit retained between calls */
  64.     int     b_ref;             /* number of open boards/devices */
  65.     char    b_brg;             /* Bus request/grant */
  66.     struct roregs   b_ro;      /* read only registers */
  67.     struct woregs   b_wo;      /* write only registers */
  68.     int     (*b_sgnl[N_SG])(); /* gpib signals */
  69.     char    b_ccc;             /* Carry cycle command */
  70.     char    b_ccf;             /* is !=0 if carry cycle used */
  71.     char    b_imr1sig;         /* imr1 bits for enabled signals */
  72.     char    b_imr2sig;         /* imr2 bits for enabled signals */
  73.     struct cc_array  b_cca;    /* carry cycle array */
  74.     struct achain  b_chain[NCHAIN];
  75.     short    b_chaincnt;
  76.     short    b_chainidx;
  77.     char    b_cmdbuf[20];      /* holds command bytes */
  78.     word_t  b_lstaddr;         /* if != -1, is last addressing on bus */
  79.     char    b_lstrsv;          /* parameter of last ibrsv call */
  80.     char    b_fdopen;          /* if !=0, there are open fd's for board */
  81.     word_t  b_sigmask;         /* mask of signals */
  82.     int     b_oddc;            /* Odd count fudge */
  83.     int     b_odda;            /* Odd address fudge */
  84.     struct  proc *b_procp;     /* copy of u_procp */
  85.     struct  buf  b_bufhdr;     /* UNIX I/O buffer */
  86.     int     b_tid;            /* timeout ID */
  87. };
  88. extern struct kboard ibboards[];
  89. extern int nibbrd;
  90.  
  91. /* board flags (b_flags) */
  92. #define BF_DMATCX       (1<<0)  /* DMA terminal count interrupt expected */
  93. #define BF_TIMEOUT      (1<<1)  /* timeout occured */
  94. #define BF_HLDOFF       (1<<2)  /* handshake heldoff */
  95. #define BF_WANTED       (1<<3)  /* waiting for exclusive use */
  96. #define BF_BUSY         (1<<4)  /* exclusive use */
  97. #define BF_STUCKSRQ     (1<<5)  /* SRQ line is stuck on */
  98. #define BF_IFCRQD       (1<<6)  /* interface clear needed */
  99. #define BF_AUTOPOLL     (1<<7)  /* perform automatic serial polls */
  100. #define BF_ONL          (1<<8)  /* board online */
  101. #define BF_2TICKS       (1<<9)  /* 2-tick timeout occured */
  102. #define BF_OREM         (1<<10) /* old value of REM bit */
  103. #define BF_OLOK         (1<<11) /* old value of LOK bit */
  104. #define BF_DMGR         (1<<14) /* device management active */
  105.  
  106. #define SPQCNT  4       /* number of stbs to keep */
  107.  
  108.  
  109. struct kdevice {
  110.     /* through d_ppe must match struct device in ugpib.h */
  111.     word_t d_uflags;     /* (see below) */
  112.     char d_bna;       /* access board number */
  113.     char d_pad,d_sad; /* primary and secondary gpib address */
  114.     char d_eos;       /* end-of-string character */
  115.     char d_tmo;       /* timeout value */
  116.     char d_ppe;       /* parallel poll enable byte */
  117.     /* internal */
  118.     unsigned d_count;   /* transfer byte count */
  119.     word_t d_flags;   /* internal flags */
  120.     word_t d_error;   /* error number */
  121.     char d_spq[SPQCNT];/*serial poll response queue (circular) */
  122.     char d_spqidx;    /* index into d_spq */
  123.     char d_spqcnt;    /* number of bytes in queue */
  124.     struct gty *d_gtyp; /* pointer to gty structure */
  125. };
  126.  
  127. /* defines to map the old idevice names to device names to reduce
  128.     code changes in the driver.  The two structures were identical,
  129.     but with different member names, one in gpib.h and one in ugpib.h */
  130. #define id_uflags d_uflags
  131. #define id_bna d_bna
  132. #define id_sad d_sad
  133. #define id_eos d_eos
  134. #define id_tmo d_tmo
  135. #define id_ppe d_ppe
  136.  
  137. /* same as above, but iboard/board */
  138. #define ib_uflags    b_uflags
  139. #define ib_addr    b_addr
  140. #define ib_pad    b_pad
  141. #define ib_sad    b_sad
  142. #define ib_eos    b_eos
  143. #define ib_tmo    b_tmo
  144. #define ib_ppe    b_ppe
  145. #define ib_irq    b_irq
  146. #define ib_ivec    b_ivec
  147. #define ib_sig    b_sig
  148.  
  149. extern struct kdevice ibdevices[];
  150. extern int nibdev;
  151.  
  152. /* device user flags (d_uflags) */
  153. /*      EOT     000001  /* assert EOI with last byte of each write */
  154. /*      HLD     000002  /* holdoff handshake at end of each read */
  155. /*      EOSM    000034  /* end-of-string modes */
  156. /*       REOS   000004  /*  terminate read on eos */
  157. /*       XEOS   000010  /*  assert EOI with eos byte */
  158. /*       BIN    000020  /*  eight-bit compare */
  159. /*      TDCL    000040  /* terminate I/O on device clear */
  160.  
  161. /* common board/device flags */
  162. #define CFLAGS (TDCL|EOSM|EOT|HLD)
  163.  
  164. /* device flags (d_flags) */
  165. #define DF_OPEN         (1<<0)  /* device is open */
  166. #define DF_CIC          (1<<2)  /* channel open as CIC */
  167. #define DF_EXCL         (1<<5)  /* device has exclusive use of board */
  168. #define DF_ESTB         (1<<6)  /* ESTB error posted */
  169. #define DF_TIK          (1<<7)  /* RQS timeout tick */
  170.  
  171.  
  172. extern unsigned ibglobals;
  173. #define G_DEBUG         (1<<0)  /* debug print statements */
  174. #define G_NOSPOLL       (1<<1)  /* no autopoll */
  175. #define G_NOSTAT        (1<<2)  /* only pass/fail status reporting */
  176. #define G_SPFC          (1<<6)  /* serial poll/fast cmd timeout change */
  177.  
  178. extern unsigned int spfc;
  179.  
  180. /* valid bits for ibwait() */
  181. #define WBITS   (TIMO|END|SRQ|LOK|REM|CIC|TACS|LACS|DTAS|DCAS)
  182.  
  183. /* bits to remember until waited upon */
  184. #define RBITS   (DTAS|DCAS)
  185.  
  186. /* ib_tmvals converts mnemonic to number of ticks */
  187. extern word_t ib_tmvals[];
  188.  
  189. /* RQS bytes */
  190. #define RQS_ON   0100                   /* positive response */
  191.  
  192. #define TM_WRQS (5*HZ)  /* 5 second sleep between checkings for rqs */
  193.  
  194. /* I/O access modes */
  195. #define USER    0       /* user virtual address */
  196. #define KERN    1       /* kernel virtual address */
  197. #define PHYS    2       /* physical address */
  198.  
  199. /* GPIB commands */
  200. #define GTL           0001     /* Go To Local                            */
  201. #define SDC           0004     /* Selected Device Clear                  */
  202. #define PPC           0005     /* Parallel Poll Configure                */
  203. #define GET           0010     /* Group Execute Trigger                  */
  204. #define TCT           0011     /* Take Control                           */
  205. #define LLO           0021     /* Local Lock Out                         */
  206. #define DCL           0024     /* Device Clear                           */
  207. #define PPU           0025     /* Parallel Poll Unconfigure              */
  208. #define SPE           0030     /* Serial Poll Enable                     */
  209. #define SPD           0031     /* Serial Poll Disable                    */
  210. #define UNL           0077     /* Unlisten                               */
  211. #define UNT           0137     /* Untalk                                 */
  212.  
  213. #define LAD             0040    /* Listen address mask */
  214. #define TAD             0100    /* Talk address mask */
  215.  
  216. #define Gaddr(p,s)      ((p)|((s)<<8))  /* gpib addresses to integer */
  217. #define NOADDR          -1              /* impossible gpib address */
  218. #
  219.